window.onload = function(){
//倒计时定时器
function getRTime(){ 
			var EndTime= new Date('2018/03/12 00:00:00'); //截止时间 
			var NowTime = new Date(); 
			var t =EndTime.getTime() - NowTime.getTime(); 
			/*var d=Math.floor(t/1000/60/60/24); 
			t-=d*(1000*60*60*24); 
			var h=Math.floor(t/1000/60/60); 
			t-=h*60*60*1000; 
			var m=Math.floor(t/1000/60); 
			t-=m*60*1000; 
			var s=Math.floor(t/1000);*/
			 
			var d=Math.floor(t/1000/60/60/24); 
			var h=Math.floor(t/1000/60/60%24); 
			var m=Math.floor(t/1000/60%60); 
			var s=Math.floor(t/1000%60); 
			 
			document.getElementById("t_d").innerHTML = d + "天"; 
			document.getElementById("t_h").innerHTML = h + "小时"; 
			document.getElementById("t_m").innerHTML = m + "分"; 
			document.getElementById("t_s").innerHTML = s + "秒"; 
		} 
		getRTime();
		setInterval(getRTime,1000);
//点击查看排行
	var goSort  = document.getElementById("goSort");
	var newPeople = document.getElementById("newPeople");
	var indexSort = document.getElementById("indexSort");
	goSort.onclick = function(){
		newPeople.style.display = "none";
		indexSort.style.display = "block";
	}
//点击返回新人列表
	var goNewPeople = document.getElementById("goNewPeople");
	goNewPeople.onclick = function(){
		newPeople.style.display = "block";
		indexSort.style.display = "none";
	}
//弹窗
	var alertBg = document.getElementById("alertBg");//弹窗背景（黑色半透明）
	var alertBody = document.getElementById("alertBody");//重复投票框
	var voteAlertBody = document.getElementById("voteAlertBody");//投票成功框（提示剩余次数）
	var noVoteBody = document.getElementById("noVoteBody");//5票之后投票框（投票失败）
	//首页新人投片
	var oIndexVote = document.getElementById("indexVote");//首页新人列表的盒子
	var oInList = oIndexVote.getElementsByTagName("a");//首页新人列表
	for(var i=0,len=oInList.length;i<len;i++){
		oInList[i].onclick = function(){
			//判断票数用完后弹窗
					//var noVoteBody = document.getElementById("noVoteBody");
					//noVoteBody.style.display = "block";
					//alertBg.style.display = "block";
			if(this.className == "unvote"){
				//首页投票成功提示
				var parent = this.parentNode.getElementsByClassName("indexNum");
				console.log(parent[1]);
				this.className = "indexvote";
				alertBg.style.display = "block";
				voteAlertBody.style.display = "block";
			}else{
				//重复投票
				alertBg.style.display = "block";
				alertBody.style.display = "block";
			}
		}
	}
	//排名投票
	var oSortVote = document.getElementById("sortVote");
	var oSaList = oSortVote.getElementsByTagName("a");
	for(var i=0,len=oSaList.length;i<len;i++){
		oSaList[i].onclick = function(){
			//判断票数用完后弹窗
					//var noVoteBody = document.getElementById("noVoteBody");
					//noVoteBody.style.display = "block";
					//alertBg.style.display = "block";
			if(this.className == "unvote"){
				//投票成功提示
				
//				console.log(this.parentNode)
//				//var ps=s.previousSbiling;  //得到s的上一个兄弟节点
				this.className = "sortVote";
				alertBg.style.display = "block";
				voteAlertBody.style.display = "block";
			}else{
				//重复投票
				alertBg.style.display = "block";
				alertBody.style.display = "block";
			}
		}
	}
	//点击确定关闭投票成功/剩余票数提示
	var closeVoteAlert = document.getElementById("closeVoteAlert");
	closeVoteAlert.onclick = function(){
		alertBg.style.display = "none";
		voteAlertBody.style.display = "none";
	}
	//投第5票引导邀请弹窗
	var fiveVote = document.getElementById("fiveVote");//首页第一个投票按钮（修改判断条件）
	var alertInviteBody = document.getElementById("alertInviteBody");//第五票框
	var closeALertVote = document.getElementById("closeALertVote");
	fiveVote.onclick = function(){//修改判断条件
		alertInviteBody.style.display = "block";
		alertBg.style.display = "block";
		this.className = "indexvote";
	}
	//点击关闭投票失败提示（第6.7.8....次投票）
	var closeNoVoteBody = document.getElementById("closeNoVoteBody");
	closeNoVoteBody.onclick = function(){
		noVoteBody.style.display = "none";
		alertBg.style.display = "none";
	}
	//点击取消关闭邀请提示
	closeALertVote.onclick = function(){
		alertInviteBody.style.display = "none";
		alertBg.style.display = "none";
	}
	//搜索不存在提示
	var searchAlertBody = document.getElementById("searchAlertBody");//搜索不存在用户框
	var searchAlert = document.getElementById("searchAlert");
	searchAlert.onclick = function(){
		searchAlertBody.style.display = "block";
		alertBg.style.display = "block";
	}
	//点击按钮关闭搜索提示
	var closeSearch = document.getElementById("closeSearch");
	closeSearch.onclick = function(){
		searchAlertBody.style.display = "none";
		alertBg.style.display = "none";
	}
	//点击黑色区域关闭所有弹窗
	alertBg.onclick = function(){
		alertBg.style.display = "none";
		alertBody.style.display = "none";
		alertInviteBody.style.display = "none";
		searchAlertBody.style.display = "none";
		voteAlertBody.style.display = "none";
	}
	//点击按钮关闭重复投票弹窗（首页、排名）
	var closeVote = document.getElementById("closeVote");//确定按钮（关闭所有弹窗）
	closeVote.onclick = function(){
		alertBg.style.display = "none";
		alertBody.style.display = "none";
	}



}